package net.edwardstx.hibernateutils.configurators;

import org.hibernate.cfg.AnnotationConfiguration;

import net.edwardstx.hibernateutils.HibernateConfigurator;

public class JNDIConfigurator implements HibernateConfigurator{

	private String										stringJNDIDatasource	= null;
	private String										stringHibernateDialect	= null;
	

	public JNDIConfigurator(String stringJNDIDatasourcNew, String stringHibernateDialectNew){
		setJNDIDatasource(stringJNDIDatasourcNew);
		setHibernateDialect(stringHibernateDialectNew);
	}
	public JNDIConfigurator(){
		
	}
	public String getJNDIDatasource() {
		return stringJNDIDatasource;
	}
	public void setJNDIDatasource(String stringJNDIDatasourcNew) {
		this.stringJNDIDatasource = stringJNDIDatasourcNew;
	}
	public String getHibernateDialect() {
		return stringHibernateDialect;
	}
	public void setHibernateDialect(String stringHibernateDialectNew) {
		this.stringHibernateDialect = stringHibernateDialectNew;
	}
	@Override
	public AnnotationConfiguration configure(AnnotationConfiguration config) {
//		logger.info("Using JNDI datasource: " + getJNDIDatasource());
		config.setProperty("hibernate.dialect",getHibernateDialect());
		config.setProperty("hibernate.connection.datasource",getJNDIDatasource());
		return config;
	}
	
}
